<?php

namespace IDock\Insurance\TPIC\Response;

use IDock\Http\Response;
use IDock\IDock\IDockEnums;
use IDock\Insurance\TPIC\Response\AllTPICResponse;
use IDock\Insurance\TPIC\TPICEnums;
use IDock\Printer\EPolicyDownloadPrinter;
use IDock\Printer\Premium\PremiumBIPrinter;
use IDock\Printer\Premium\PremiumCIPrinter;
use IDock\Printer\Premium\PremiumCoveragePrinter;
use IDock\Printer\Premium\PremiumFactorPrinter;
use IDock\Printer\Premium\PremiumInquiryPrinter;
use IDock\Printer\Premium\PremiumTaxPrinter;
use IDock\Printer\PremiumUnderwritingPrinter;
use IDock\Printer\UploadFilePrinter;
use IDock\Printer\VehicleModelPrinter;
use IDock\Printer\VehiclePrinter;

class ElecPolicyDownloadResponse extends AllTPICResponse
{
    public $printer = EPolicyDownloadPrinter::class;
    public function printerInit() :Response
    {
        $elecPrinter = new EPolicyDownloadPrinter();

        $data = $this->getBody();
        $elecPrinter->data = $data['body']['elecPolicyInfoList']['elecFile'] ?? '';
        $elecPrinter->url = $data['body']['elecPolicyInfoList']['fcInternetFilePath'] ?? '';
        if(!empty($elecPrinter->data)){
            $elecPrinter->data = base64_decode($elecPrinter->data);
        }
        $elecPrinter->finish = true;
        if(empty($elecPrinter->data) && empty($elecPrinter->url)){
            $elecPrinter->finish = false;
        }
        $this->printer = $elecPrinter;

        return $this;
    }

}
